<script type="text/javascript">
function validate_form() {
    <?php
        if(count($this->language) > 0) :
            foreach($this->language as $value) :
    ?>
    if($('#tabs-<?php echo $value['locale'] ?>').hasClass('ui-tabs-hide') == false) {
        var name_<?php echo $value['locale'] ?> = $('#name-<?php echo $value['locale'] ?>').val();
        var phone = $('#phone').val();
        var yahoo = $('#yahoo').val();
        var skype = $('#skype').val();
        var msn = $('#msn').val();
        var qq = $('#qq').val();
        var countError = 0;
        if((name_<?php echo $value['locale'] ?>.length < 1) || (name_<?php echo $value['locale'] ?>.length > 50)) {
            $('#errorName-<?php echo $value['locale'] ?>').html('Tên liên lạc từ 1-50 kí tự');
            countError++;
        }
        else {
            $('#errorName-<?php echo $value['locale'] ?>').html('');
        }
        if((phone.length < 1) || (phone.length > 20)) {
            $('#errorPhone').html('Số điện thoại từ 1-20 kí tự');
            countError++;
        }
        else {
            $('#errorPhone').html('');
        }
        if(yahoo.length > 50) {
            $('#errorYahoo').html('Tài khoản Yahoo tối đa 50 kí tự');
            countError++;
        }
        else {
            $('#errorYahoo').html('');
        }
        if(skype.length > 50) {
            $('#errorSkype').html('Tài khoản Skype tối đa 50 kí tự');
            countError++;
        }
        else {
            $('#errorSkype').html('');
        }
        if(msn.length > 50) {
            $('#errorMsn').html('Tài khoản MSN tối đa 50 kí tự');
            countError++;
        }
        else {
            $('#errorMsn').html('');
        }
        if(qq.length > 50) {
            $('#errorQQ').html('Tài khoản QQ tối đa 50 kí tự');
            countError++;
        }
        else {
            $('#errorQQ').html('');
        }
        if(countError > 0) {
            return false;
        }
        else {
            return true;
        }
    }
    <?php
            endforeach;
        endif;
    ?>
};
</script>
    <div class="list_category">
        <ul>
            <li><a href="<?php echo $this->baseUrl('admincp/contact'); ?>">Quản lý liên hệ</a></li>
            <li><a href="<?php echo $this->baseUrl('admincp/contact/create'); ?>">Tạo liên hệ mới</a></li>
        </ul>
    </div>
</div>

<!-- Begin Content -->
<div class="section">
    <div class="heading_section">
        <span>Sửa thông tin liên lạc</span>
    </div>
    
    <div class="content">
    <form action="" method="post" onsubmit="return validate_form()">
        <div id="tabs">
            <ul>
                <?php
                    if(count($this->language) > 0) :
                        foreach($this->language as $value) :
                ?>
                    <li><a href="#tabs-<?php echo $value['locale']; ?>"><?php echo $value['name']; ?></a></li>
                <?php
                        endforeach;
                    endif;
                ?>
            </ul>
            <?php
                if(count($this->data) > 0) :
                    foreach($this->data as $value) :
            ?>
            <div id="tabs-<?php echo $value['locale']; ?>">
                <table class="table">
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('name-'.$value['locale'],'Tên liên lạc'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formText('name-'.$value['locale'],$value['name'],array('class'=>'input')); ?></td>
                        <td class="td3" id="errorName-<?php echo $value['locale'] ?>"></td>
                    </tr>
                </table>
            </div>
            <?php
                    endforeach;
                endif;
            ?>
            
            <table class="table">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('phone','Điện thoại'); ?>&nbsp;<span class="error-msg">*</span></td>
                    <td class="td2"><?php echo $this->formText('phone',$this->contact['phone'],array('class'=>'input')); ?></td>
                    <td class="td3" id="errorPhone"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('yahoo','Yahoo'); ?>&nbsp;&nbsp;&nbsp;</td>
                    <td class="td2"><?php echo $this->formText('yahoo',$this->contact['yahoo'],array('class'=>'input')); ?></td>
                    <td class="td3" id="errorYahoo"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('skype','Skype'); ?>&nbsp;&nbsp;&nbsp;</td>
                    <td class="td2"><?php echo $this->formText('skype',$this->contact['skype'],array('class'=>'input')); ?></td>
                    <td class="td3" id="errorSkype"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('msn','MSN'); ?>&nbsp;&nbsp;&nbsp;</td>
                    <td class="td2"><?php echo $this->formText('msn',$this->contact['msn'],array('class'=>'input')); ?></td>
                    <td class="td3" id="errorMsn"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('qq','QQ'); ?>&nbsp;&nbsp;&nbsp;</td>
                    <td class="td2"><?php echo $this->formText('qq',$this->contact['qq'],array('class'=>'input')); ?></td>
                    <td class="td3" id="errorQQ"></td>
                </tr>
                <tr>
                    <td class="td1">&nbsp;</td>
                    <td class="td2">
                        <?php echo $this->formSubmit('submit','Cập nhật',array('class'=>'button')); ?>
                        <?php echo $this->formReset('reset','Nhập lại',array('class'=>'button')); ?>
                    </td>
                    <td class="td3"></td>
                </tr>
            </table>
        </div>
    </form>
    </div>
</div>
<!-- End Content -->